<template>
  <div v-show="visible" class="base-dialog-mask">
    <div class="dialog">
      <div class="header">
        <h3><slot name="title"></slot></h3>
        <span @click="close" class="close" >×</span>
      </div>
      <div class="container">
        <slot name="content">默认内容</slot>
      </div>
      <div class="footer">
        <button @click="close">确认</button>
        <button @click="close">取消</button>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  props: {
    visible: Boolean,
  },
  methods: {
    close() {
      this.$emit('update:visible',false);
    }
  }
};
</script>

<style scoped>
.base-dialog-mask {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.5);
  z-index: 9999;
  box-sizing: border-box;
}
.dialog {
  width: 500px;
  height: 350px;
  /* 水平居中 */
  margin: 0 auto;
  /* 垂直居中 */
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background-color: white;
  border-radius: 10px;
  box-shadow: 0 0 10px rgba(0, 0, 0, 0.5);
  background-color: white;
  box-shadow: 1px 1px 5px black;
}
.header {
  display: flex;
  justify-content: space-between;
  height: 50px;
  line-height: 50px;
  border-bottom: 2px solid gray;
  padding: 0 20px;
  /* 垂直居中 */
  align-items: center;
}
.container {
  /* 使用全部空间 */

  height: 200px;
  /* 垂直居中 */
  text-align: center;
  padding: 20px;
}
.footer {
  border-top: 2px solid gray;
  height: 50px;
  display: flex;

  /* 右侧对齐 */
  align-items: center;
  justify-content: flex-end;
  padding: 0 20px;
}
</style>